<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理员登录-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="./static/css/font.css">
    <link rel="stylesheet" href="./static/css/weadmin.css">
    <script type="text/javascript" src="./static/js/jquery-latest.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>

</head>
<body class="login-bg">

<div class="login">
    <div class="message">比价宝</div>
    <div id="darkbannerwrap"></div>

    <form method="post" action="#">
        <input id="username" name="username" placeholder="邮箱" type="text">
        <hr class="hr15">
        <input id="password" name="password" placeholder="密码" type="password">
        <hr class="hr15">
        <input id="loginBtn" value="登录" style="width:100%;" type="button">
        <hr class="hr20">
    </form>
    <form method="post" action="/register" >
        <input id="loginBtn2" value="没有账号? 点此注册" style="width:100%;" type="submit">
        <hr class="hr20">
    </form>
</div>

<script type="text/javascript">
    $(function () {
        $("#loginBtn").click(function () {
            var username = $("#username").val();//取值
            var password = $("#password").val();
            if (!username) {
                alert("用户名必填!");
                $("#username").focus();//获取焦点
                return;
            }
            if (!password) {
                alert("密码必填!");
                $("#password").focus();//获取焦点
                return;
            }
            var email = /^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$/;
            if(!email.test(username)){
                alert("用户名必须为邮箱格式！");
                $("#username").focus();//获取焦点
                return;
            }
            //var param = "username="+username+"&password="+password;
            var param = {"username": username, "password": password};
            $.post("/loginverify", param, function (result) {
                if (result) {
                    window.location.href = "index";
                } else {
                    alert("用户名或者密码错误!");
                }
            });
        });
    });
</script>

</body>
</html>